package com.abcd.sign;

import java.io.UnsupportedEncodingException;
import java.security.NoSuchAlgorithmException;
import java.util.Date;
import java.util.LinkedHashMap;
import java.util.Map;

import org.apache.commons.codec.digest.HmacUtils;

/**
 * @program: java-base
 * @description: Md5加密方式
 * @author: Liu
 **/
public class Md5 {

    public static void main(String[] args) throws NoSuchAlgorithmException, UnsupportedEncodingException {

        Map<String, String> result = new LinkedHashMap<>(7);

        result.put("agentId", "abc");
        result.put("time", SignUtils.formatSync_yMdTHmsZ(new Date()));
        result.put("couponNum", "zc1234567891234567890");
        result.put("shopsNum", "123");
        result.put("shopsName", "abc");

        String date = SignUtils.formatSync_yMdTHmsZ(new Date());
        System.out.println(date);
        String linkStr = SignUtils.createLinkStringWithoutParamName(result);
        System.out.println(linkStr);

        String abc = "agentId=123123&couponNum=210907082104263EF61&time=2021-09-07 08:36:10&key=testSecretKey";
        String md = HmacUtils.hmacMd5Hex(abc, abc);
        System.out.println(md);
        String s = md.toUpperCase();
        System.out.println(s);

        String test = "zc1234567891234678889";
        boolean b = SignUtils.pointRegex(test);
        System.out.println(b);

        String md5Str = SignUtils.md5(abc);
        System.out.println(md5Str.toUpperCase());
    }
}